<template>
  <!-- 布局 -->
  <div class="common_layout">
    <el-container>
      <el-aside width="200px">
        <el-menu
          active-text-color="#ffd04b"
          background-color="#101924"
          class="el-menu-vertical-demo"
          default-active="2"
          text-color="#fff"
          style="height: 1100px"
        >
          <div style="height: 70px;width: 180px;text-align: center;">
            <img src="../views/Img/38e17df59519b56e88f01c364d12ca66.png" alt="" style="width: 35px;height: 23px;float: left;margin-top: 20px;margin-left: 30px;">
          <span style="font-size: 25px;color: firebrick;float: left;margin-top: 10px;">赫龙</span>
          <p style="color: white;float: left;margin-top: 23px">V3.0</p>
          </div>
          <el-menu-item
            index="1-1"
            style="color: aliceblue; background-color: red"
            >首页</el-menu-item
          >
          <el-menu-item index="1-2" style="color: aliceblue"
          @click="dialogFormVisible2=true">系统配置</el-menu-item
          >
          <el-menu-item index="1-3" style="color: aliceblue;" @click="dialogTableVisible=true">主数据</el-menu-item>
                  <el-menu-item index="1-4" style="color: aliceblue;" @click="dialogFormVisible=true">制造管理</el-menu-item>
                  <el-menu-item index="1-5" style="color: aliceblue;" @click="dialogFormVisible1=true">订单与合同</el-menu-item>
          <el-menu-item index="1-6" style="color: aliceblue"
            @click="WarehouseVisible=true" >库房管理</el-menu-item
          >
          <el-menu-item index="1-7" style="color: aliceblue"
            >应收应付</el-menu-item
          >
          <el-menu-item index="1-8" style="color: aliceblue"
            >固定资产</el-menu-item
          >
          <el-menu-item index="1-9" style="color: aliceblue"
            >子分类账管理</el-menu-item
          >
          <el-menu-item index="1-10" style="color: aliceblue"
            >成本核算</el-menu-item
          >
          <el-menu-item index="1-11" style="color: aliceblue"
            >总账管理</el-menu-item
          >
          <el-menu-item index="1-12" style="color: aliceblue"
            >计划预算系统</el-menu-item
          >
          <el-menu-item index="1-13" style="color: aliceblue"
            >运输管理系统</el-menu-item
          >
          <el-menu-item index="1-14" style="color: aliceblue"
           @click="dialogTableVisiblser=true" >报表系统</el-menu-item
          >
        </el-menu>
      </el-aside>
      <el-dialog v-model="dialogTableVisible" title="客商主数据" width="500" style="margin-left: 200px;margin-top: 60px;width: 600px;">
                <el-menu class="el-menu-vertical-demos" default-active="2" style="height: 300px;" >
                    <el-menu-item index="1-1" @click="Customer()" >客户管理</el-menu-item>
                <el-menu-item index="1-2" @click="Supplier()">供应商管理</el-menu-item>
                </el-menu>

      </el-dialog>

      <el-dialog v-model="dialogTableVisiblser" title="报表" width="500" style="margin-left: 200px;margin-top: 60px;width: 600px;">
                <el-menu class="el-menu-vertical-demos" default-active="2" style="height: 300px;" >
                    <el-menu-item index="1-1" @click="StorageSReport()" >入库统计表</el-menu-item>
                    <el-menu-item index="1-2" @click="">出库统计表</el-menu-item>
                    <el-menu-item index="1-3" @click="">工单执行进度看板</el-menu-item>
                    <el-menu-item index="1-4" @click="">智能车间管控大屏</el-menu-item>
                    <el-menu-item index="1-5" @click="WorM()">库存管理报表</el-menu-item>
                </el-menu>

      </el-dialog>

      <el-dialog v-model="dialogFormVisible2" title="用户与权限" width="500" style="margin-left: 200px;margin-top: 60px;width: 600px;">
          <el-menu class="el-menu-vertical-demos" default-active="2" style="height: 300px;width: 200px;" >
              <el-menu-item index="1-1" @click="UrseTer()" >用户管理</el-menu-item>
              <el-menu-item index="1-2" @click="Roleten()">角色管理</el-menu-item>
              <el-menu-item index="1-3" @click="Premiss()">权限管理</el-menu-item>
              
          </el-menu>
          <span style="float: right;margin-top: -343px;margin-right: 300px;"><h3>职员与组织</h3></span>
                <el-menu class="el-menu-vertical-demos" default-active="2" style="height: 300px;float: right;margin-top: -300px;margin-right: 220px;" >
                <el-menu-item index="1-1" @click="Depat()">部门管理</el-menu-item>
                <el-menu-item index="1-2" @click="Enter()" >企业管理</el-menu-item>
              </el-menu>

      </el-dialog>

      <el-dialog v-model="dialogFormVisible" title="基础数据" width="500"
        style="margin-left: 200px; margin-top: 60px; width: 600px;height: 500px;">
        <el-menu class="el-menu-vertical-demos" default-active="2" style="height: 300px;width: 130px;; width: 180px;">
          <el-menu-item index="1-1" @click="Resource()">资源管理</el-menu-item>
          <el-menu-item
            index="1-2"
            @click="router.push('/WorkCenters/WorkCenterShowHtml')"
            >工作中心</el-menu-item
          >
          <el-menu-item index="1-3" @click="Bills()">物料清单(BOM)</el-menu-item>
          <el-menu-item index="1-3" @click="router.push('/ShowProcessData'),dialogFormVisible=false">工序</el-menu-item>
          <el-menu-item index="1-3" @click="router.push('/ProducManagement/ProcessRouteQuery')">工艺路线</el-menu-item>
        </el-menu>
      </el-dialog>
      <!-- 库房管理 -->
      <el-dialog
        v-model="WarehouseVisible"
        width="500"
        style="margin-left: 230px; margin-top: 60px; width: 600px"
      >
      <el-menu class="el-menu-vertical-demos" style="height: 500px;width: 130px;">
        <h2>仓库管理</h2>
        <el-menu-item index="1-1" @click="router.push('/ShowWarehouse'),WarehouseVisible=false">仓库及初始化</el-menu-item>
          <el-menu-item index="1-2" @click="router.push('/ShowWarehouse'),WarehouseVisible=false">库存管理</el-menu-item>
          <el-menu-item index="1-3" @click="router.push('/ShowWarehouse'),WarehouseVisible=false">库存盘点</el-menu-item>
          <el-menu-item index="1-4">库存调拨</el-menu-item>
          <el-menu-item index="1-5">组装拆卸单</el-menu-item>
          <el-menu-item index="1-4">工序</el-menu-item>
          <el-menu-item index="1-5" @click="Process()">工艺路线</el-menu-item>
          <el-menu-item index="1-6" @click="Mater()">物料管理</el-menu-item>
      </el-menu>
      <el-menu class="el-menu-vertical-demos" style="width: 130px;float:right;margin-top: -500px;margin-right: 300px;">
        <h2>入库管理</h2>
        <el-menu-item index="1-1" @click="Storages()">入库列表</el-menu-item>
      </el-menu>
      </el-dialog>
      <el-dialog v-model="dialogFormVisible1" title="协议管理" width="500" style="margin-left: 200px;margin-top: 60px;width: 600px;">
          <el-menu class="el-menu-vertical-demos" default-active="2" style="height: 300px;width: 200px;" >
                <el-menu-item index="1-1" >采购协议</el-menu-item>
                <el-menu-item index="1-2" >销售协议</el-menu-item>
                </el-menu>
                <span style="float: right;margin-top: -343px;margin-right: 300px;"><h3>订单管理</h3></span>
                <el-menu class="el-menu-vertical-demos" default-active="2" style="height: 300px;float: right;margin-top: -300px;margin-right: 220px;" >
                <el-menu-item index="1-1" @click="Purchasing()" >采购/委外订单</el-menu-item>
                <el-menu-item index="1-2" @click="orderBy()" >销售订单</el-menu-item>
          </el-menu>
        </el-dialog>
      <el-container>
        <el-header style=" background-color: white;">

            <el-menu
              :default-active="activeIndex"
              class="el-menu-demo"
              mode="horizontal"
              @select="handleSelect"
            >
              <el-menu-item index="1">ERP系统</el-menu-item>
              <el-menu-item index="2">CRM系统</el-menu-item>
              <el-menu-item index="3">项目管理</el-menu-item>
              <el-menu-item index="4">HRMS系统</el-menu-item>
              <el-menu-item index="5">OA系统</el-menu-item>

              <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
            style="width: 30px;height: 30px;margin-left: 700px;margin-top: 15px;" />
            <span style="margin-top: 20px;margin-left: 10px;">
              {{ UserName }}
            </span>
            
            
            <el-link  style="color: black;float: right;margin-top: 8px;margin-left: 30px;"  @click="router.push({ name: 'Login' })">
              <img src="../views/Img/屏幕截图 2024-12-23 134129.png" style="width: 20px;height: 20px;" />
              退出</el-link>
            </el-menu>

        </el-header>
        <el-main style="background-color: #dcdcdc">
          <RouterView />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import { useRouter } from "vue-router";
const router = useRouter();
import { onMounted, ref } from "vue";
const dialogTableVisible = ref(false);
const dialogFormVisible = ref(false);
const WarehouseVisible = ref(false);
const dialogFormVisible1 = ref(false)
const dialogFormVisible2=ref(false)
const dialogTableVisiblser=ref(false)
const activeIndex = ref('1')

const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}

const formLabelWidth = "140px";
const Resource = () => {
  router.push({ name: "ResourceShow" });
  dialogFormVisible.value = false;
};

//判断该登录的用户是否有权限进行RBAC的操作
const IsShow = ref(false);
const AdminIsShow = ref(false);
const UserList = ref([]);
const UserName = ref("");
const LoadUserJSONData = () => {
  //读出数据
  const value = localStorage.getItem("userInfo");
  //反序列化JSON字符串
  UserList.value = JSON.parse(value);
  UserList.value.forEach((item: any) => {
  UserName.value = item.userName;
    if (item.roleName == "超级管理员" || item.permissionName == "所有操作") {
      IsShow.value = true;
    }
    if (item.roleName == "管理员" || item.permissionName == "添加用户信息") {
      AdminIsShow.value = true;
    }
  });
};


onMounted(() => {
  //LoadUserJSONData();
});


//客户
const Customer = () => {
  router.push({ name: 'CustomerShow' })
  dialogTableVisible.value = false
}
//订单
const orderBy = () => {
  router.push({ name: 'OrdersShow' })
  dialogFormVisible1.value = false
}
//用户
const UrseTer=()=>{
    router.push({ name: 'AddUserDataHtml' })
    dialogFormVisible2.value=false
}
//角色
const Roleten=()=>{
    router.push({ name: 'AddRoleDataHtml' })
    dialogFormVisible2.value=false
}
//权限
const Premiss=()=>{
    router.push({ name: 'AddPremissionDataHtml' })
    dialogFormVisible2.value=false
}
//部门
const Depat=()=>{
    router.push({ name: 'DepartmentQuery' })
    dialogFormVisible2.value=false
}
//企业
const Enter=()=>{
    router.push({ name: 'EnterpriseQuery' })
    dialogFormVisible2.value=false
}

//物料清单
const Bills=()=>{
    router.push({ name: 'BillMaterialsList' })
    dialogFormVisible.value=false
}

//工艺管理
const Process=()=>{
    router.push({ name: 'ProcessRouteQuery' })
    dialogFormVisible.value=false
}

//物料管理
const Mater=()=>{
    router.push({ name: 'MaterialManagementList' })
    dialogFormVisible.value=false
}

//供应商
const Supplier=()=>{
    router.push({ name: 'SuppliersQuery' })
    dialogTableVisible.value=false
}
//采购/委外订单
const Purchasing=()=>{
    router.push({ name: 'PurchasingsQuery' })
    dialogTableVisible.value=false
}
//入库管理
const Storages=()=>{
    router.push({ name: 'StorageShow' })
    WarehouseVisible.value=false
}

//入库报表
const StorageSReport=()=>{
  router.push({ name: 'StorageReport' })
  dialogTableVisiblser.value=false
}
//库存清单帆软报表导出
const WorM = ()=>{
  router.push({ name: 'WorMHtml' })
  dialogTableVisiblser.value=false
}

</script>

<style scoped>
.el-menu-vertical-demo .el-menu-item:hover {
  background-color: #0c2135;
}

.el-menu-vertical-demos .el-menu-item:hover {
  background-color: #e078a0;
}
.el-link {
  margin-right: 8px;
}
.el-link .el-icon--right.el-icon {
  vertical-align: text-bottom;
}
</style>
